import { request } from 'umi';

/** 获取当前的用户 GET /api/currentUser */
export async function createImgMsg(options?: { [key: string]: any }) {
  return request('/login/createImgMsg', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 登录接口 POST /api/login/account */
export async function login(body: API.LoginParams, options?: { [key: string]: any }) {
  return request<API.LoginResult>('/login/user', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 获取用户菜单 */
export async function getCurrentUserMenu(body: API.LoginParams, options?: { [key: string]: any }) {
  return request<API.LoginResult>('/sys/role/load/menu', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}
/** 获取用户菜单 */
export async function getCurrentUserMenuOnly(
  body: API.LoginParams,
  options?: { [key: string]: any },
) {
  return request<API.LoginResult>('/sys/menu/getCurentTreeList?menuType=1', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}
//退出登录
export async function logout() {
  return request<API.LoginResult>('/login/logout', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
    },
  });
}
